package BanyuanClub.Work.Story.Five;

import java.io.ObjectInputStream;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

public class Text {
    public static void main(String[] args) {
        System.out.println("教务系统入口");
        Scanner in = new Scanner(System.in);
        Datebase db = new Datebase();
        while (true){
            System.out.println("请选择：1.增 2.删 3.改 4.查 0.退");
            int input = in.nextInt();
            switch (input){
                case 1:{
                    System.out.println("学号");
                    String id = in.next();
                    System.out.println("姓名");
                    String name = in.next();
                    while (true){
                        System.out.println("年龄");
                        String sage = in.next();
                        if (sage.matches("\\d{1,2}")){
                            int age = Integer.parseInt(sage);
                            db.insert(new Student(id,name,age));
                            break;
                        }
                        System.out.println("输入错误");
                    }
                    System.out.println("成功");
                    break;
                }
                case 2:{
                    System.out.println("学号");
                    String st = in.next();
                    db.delete(st);
                    System.out.println("已删");
                    break;
                }
                case 3:{
                    System.out.println("学号");
                    String id = in.next();
                    System.out.println("姓名");
                    String name = in.next();
                    while (true){
                        System.out.println("年龄");
                        String sage = in.next();
                        if (sage.matches("\\d{1,2}")){
                            int age = Integer.parseInt(sage);
                            db.update(new Student(id,name,age));
                            break;
                        }
                        System.out.println("输入错误");
                    }
                    System.out.println("成功");
                    break;

                }
                default:{
                    System.exit(0);
                }
            }
        }
    }
}
